#include "bone.h"

Bone::Bone() {
   name = "";
   direction = Vector3D(0.0, 0.0, 0.0);
   length = 0.0; 
   axisOrder = "";
}

Bone::~Bone() {
}

void Bone::setAxisRot(Vector3D a, string order, bool isDeg) {
   
   rotationAxis = a;
   rotAxisOrder = order;

   axisX = Vector3D(1.0, 0.0, 0.0);
   axisY = Vector3D(0.0, 1.0, 0.0);
   axisZ = Vector3D(0.0, 0.0, 1.0);
   
   for (int i = order.size() - 1; i >= 0; i--) {
      if (order[i] == 'X' && a[0] != 0) {
         axisY = rotate(a[0], axisY, axisX, isDeg);
         axisZ = rotate(a[0], axisZ, axisX, isDeg);
      } else if (order[i] == 'Y' && a[1] != 0) {
         axisX = rotate(a[1], axisX, axisY, isDeg);
         axisZ = rotate(a[1], axisZ, axisY, isDeg);
      } else if (order[i] == 'Z' && a[2] != 0) {
         axisX = rotate(a[2], axisX, axisZ, isDeg);
         axisY = rotate(a[2], axisY, axisZ, isDeg);
      }
   }
}

Vector3D Bone::lenXdir(){
   return length * direction;
}
